//
//  MusicCDWidget.swift
//  TimMusic
//
//  Created by nkl on 2024/10/17.
//

import Foundation
import SwiftUI

struct MusicCDWidget: View {
    var hasArrow: Bool
    var bgColor: Color = .black
    var model: ControlMusicModel
    var body: some View {
        ZStack {
            bgColor.ignoresSafeArea()
            
            Group {
                Image("ic_cd")
                if let data = model.imageData, let uiImage = UIImage(data: data) {
                    Image(uiImage: uiImage)
                        .resizable()
                        .cornerRadius(40)
                        .frame(width: 80, height: 80)
                } else {
                    Image("ic_small_placeholder")
                        .resizable()
                        .cornerRadius(40)
                        .frame(width: 80, height: 80)
                }

            }.makeCircleRotation(isActive: model.isPlay)

            if hasArrow {
                HStack {
                    Spacer()
                    Image("ic_cd_arrow").padding(.trailing, 20)
                }.offset(y: -20)
            }
        }
    }
}
